package com.tzjw.marketweixin.pojo.form;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author stone
 * @date 2022/01/06 16:37
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseForm {
    Integer page;
    Integer limit;
    String sort;
    String order;

    /**
     * 检查该查询条件对象是否含非法参数,替换非法参数
     * 默认值如下:
     *      limit 0
     *      page 0
     *      sort add_time
     *      order desc
     * @author hayden
     * @since 2023/09/02 14:40
     */
    public void checkInvalidQueryParam() {
        if (this.getPage() == null) {
            this.setPage(0);
        }

        if (this.getLimit() == null) {
            this.setLimit(0);
        }

        if (this.getSort() == null) {
            this.setSort("add_time");
        }

        if (this.getOrder() == null) {
            this.setOrder("desc");
        }
    }
}
